{% extends "./inc/base.html" %}
{% block style%}
<link rel="stylesheet" href="/static/admin/js/datatables/datatables.css" type="text/css"/>
<style>
    .i-checks{
        display: inline-block;
        width: 100px;
        overflow: hidden;
        padding-top: 0px !important;
    }
    .panel .table td, .panel .table th {
        padding-bottom: 0px;
        padding-top: 10px;
    }
</style>
{% endblock %}
{% block content %}
<section class="hbox stretch">
    <section class="vbox">
        <header class="header bg-light dk">
            {#
            <div class="btn-group pull-right">
                <button data-toggle="dropdown" class="btn btn-sm btn-default dropdown-toggle">
                    <span class="dropdown-label">{{ this_role.desc }}</span>
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu dropdown-select accessselect">
                    {% for item in auth_role %}
                    <li {%if thisid== item.id %}class="active" {% endif %}><input name="d-s-r" checked="" type="radio"
                                                                                  value="/admin/auth/access/?id={{item.id}}"><a
                            href="#">{{ item.desc }}</a></li>
                    {% endfor %}
                    <li class="disabled"><input name="d-s-r" disabled="" type="radio"><a href="#">I'm disabled</a></li>

                </ul>

            </div>
            #}
            <ul class="nav nav-tabs pull-left">
                <li class=""><a href="/admin/auth/access/?id={{controller.get('id')}}"><i class="fa fa-comments text-muted"></i> 权限设置 </a></li>
                <li class="active"><a href="/admin/auth/catepriv/?id={{controller.get('id')}}"><i class="fa fa-user text-muted"></i> 栏目权限</a></li>
                <li class=""><a href="/admin/auth/userlist/?id={{controller.get('id')}}"><i class="fa fa-user text-muted"></i> 成员管理</a></li>
            </ul>
        </header>
        <section class="scrollable wrapper">
            <form action="/admin/auth/catepriv" class="form-horizontal" method="post" data-validate="parsley">
            <section class="panel panel-default">
                <header class="panel-heading">
                    {{controller.meta_title}}
                    <i title="" data-original-title="" class="fa fa-info-sign text-muted" data-toggle="tooltip" data-placement="bottom" data-title=""><i class="fa fa-question-circle"></i></i>
                </header>
                <div class="row wrapper">

                    <div class="col-sm-9 m-b-xs">
                        <div class="">
                            <a href="#" onclick="jQuery('#category').treetable('expandAll'); return false;" class="btn btn-sm btn-info ">
                                展开全部
                            </a>
                            <a  onclick="jQuery('#category').treetable('collapseAll'); return false;" href="#" class="btn btn-sm btn-info">
                                合并全部
                            </a>

                        </div>
                    </div>

                </div>
                <div class="table-responsive">
                    <table class="table table-hover b-t b-light treetable" id="category">
                        <thead class="bg-light dk">
                        <tr>
                            <th > <label class="checkbox m-n i-checks">分类名称 </label></th>
                            <th > <label class="checkbox m-n i-checks"><input type="checkbox" name=""><i></i>全选</label></th>
                        </tr>
                        </thead>
                        <tbody>
                        {%for val in tree%}
                        <tr data-tt-id="{{val.id}}" {%if val.pid != 0 %} data-tt-parent-id="{{val.pid}}"{%else%}class="active" {%endif%}>
                            <td><span class='folder ui-draggable'>{{val.title}}</span></td>
                            <td>
                                {%if val.mold==0%}
                                {%set roleid = config.setup.SYS_PRIV_ROLE%}
                                {%elif val.mold==1%}
                                {%set ispriv = val.model|getmode('priv_show')%}
                                {%if ispriv==1%}
                                {%set priv_roleid = val.model|getmode('priv_roleid')%}
                                {%if priv_roleid|length>0%}
                                {%set roleid = priv_roleid|parse_config_attr%}
                                {%endif%}
                                {%endif%}
                                {%elif val.mold==2%}
                                {%set roleid = config.setup.SP_PRIV_ROLE %}
                                {%endif%}
                                {% for index, items in roleid %}
                                <label class="checkbox m-n i-checks"><input  type="checkbox" name="priv_roleid" value="{{index}},{{val.id}},{{controller.get('id')}}" {%if val.id|priv(controller.get('id'),index,1,false)%} checked{%endif%}><i></i>{{items}}</label>
                                {%endfor%}
                            </td>
                        </tr>
                        {%endfor%}


                        </tbody>
                    </table>
                </div>
                <footer class="panel-footer">
                    <div class="row">


                        <div class="col-sm-12  text-center">
                            <input type="hidden" value="{{controller.get('id')}}" name="roleid">
                            <button type="submit"  class="btn btn-primary ajax-post" target-form="form-horizontal">提交</button>
                        </div>
                    </div>
                </footer>
            </section>
            </form>
        </section>
    </section>

</section>
{% endblock%}

{% block script%}
<script src="/static/admin/js/parsley/parsley.min.js"></script>
<script src="/static/admin/js/parsley/parsley.extend.js"></script>
<script src="/static/admin/js/treetable/jquery.treetable.js" type="text/javascript"></script>
<script type="text/javascript">
    $("#category").treetable({ expandable: true });
    jQuery('#category').treetable('expandAll')

</script>
{% endblock %}